package hz.mobileproject.pda.ui.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.vivian.timelineitemdecoration.util.Util;

import java.util.List;

import hz.mobileproject.pda.R;
import hz.mobileproject.pda.entity.response.Event;
import hz.mobileproject.pda.entity.response.Response_QueryCallRoll;
import hz.mobileproject.pda.entity.response.Response_loadPrisonerList;

/**
 * *          _       _
 * *   __   _(_)_   _(_) __ _ _ __
 * *   \ \ / / \ \ / / |/ _` | '_ \
 * *    \ V /| |\ V /| | (_| | | | |
 * *     \_/ |_| \_/ |_|\__,_|_| |_|
 * <p>
 * Created by vivian on 2017/6/9.
 */

public class DotTimeLineAdapter extends RecyclerView.Adapter<DotTimeLineAdapter.ViewHolder> {
    Context mContext;
    List<Response_QueryCallRoll> mList;
    int[] colors = {0xffFFAD6C, 0xff62f434, 0xffdeda78, 0xff7EDCFF, 0xff58fdea, 0xfffdc75f};//颜色组

    public void setList(List<Response_QueryCallRoll> list) {
        mList = list;
        notifyDataSetChanged();
    }

    public DotTimeLineAdapter(Context context) {
        mContext = context;
    }

    public DotTimeLineAdapter(Context context, List<Response_QueryCallRoll> list) {
        mContext = context;
        mList = list;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.pop_item, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        holder.start_time.setText(mList.get(position).getStart_time()+"");
        holder.end_time.setText(mList.get(position).getEnd_time()+"");
        holder.police_code.setText(mList.get(position).getPolice_code()+"");
        holder.num.setText(mList.get(position).getCall_total_num()+"");
//        holder.time.setTextColor(colors[position % colors.length]);
    }

    @Override
    public int getItemCount() {
        return mList==null?0:mList.size();

    }

    class ViewHolder extends RecyclerView.ViewHolder {
        TextView start_time;
        TextView police_code;
        TextView num;
        TextView end_time;

        public ViewHolder(View view) {
            super(view);
            start_time = (TextView) view.findViewById(R.id.start_time);
            police_code = (TextView) view.findViewById(R.id.police_code);
            num = (TextView) view.findViewById(R.id.num);
            end_time = (TextView) view.findViewById(R.id.end_time);
        }
    }


}
